<?php
header('Content-Type: text/html; charset=UTF-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>做业(比大小)</title>
  <script type='text/javascript' src='query/jquery-1.11.1.min.js'></script>
  <script type='text/javascript'>
	$(function(){
		$('.start').click(function(){
			$('.main').css('display','none');
			$('.plat').css('display','block');
			});
		var a=0;
		var i=3;
		var p=0;
		function you(){
			$('#alert').html("");
		}
		$('#compare').click(function(){
			if($(this).html() == "比一比"){
				$(this).html("暂停"); 
				num = setInterval(function(){
					t = parseInt(Math.random()*999);
					if(t>0&&t<10){
						t = '0';
					}else{
						t = t;
						}
					$('#div6').html(t);
					
					m = parseInt(Math.random()*999);
					if(t>0&&t<10){
						m = '0';
					}else{
						m = m;
						}
					$('#div0').html(m);
					
					},40);
					}else if($(this).html() == "暂停"){
						$('#compare').html("比一比");
						var div6 = $('#div6').val();	
						var div0 = $('#div0').val();

						clearInterval(num);
					
						if(m>t){
							m-=t;
							a+=m;
							
							$('#alert').html('你赢了，游戏分数加'+a);
							setTimeout(you,3000);
							$('#span').html(a); 
							
							}else{
								i-=1;
								$('#span1').html(i);
								if(i!=0){
									$('#alert').html('你输了，扣除生命力   1');
									setTimeout(you,3000);
									$('#span1').html(i);

								}else{ 
									var z = prompt('雁过留声，人过留名！');
									location.href="index.php";
									
								}
						}
					}
			});
		$('#stop').click(function(){
			var flag = confirm('确定不玩了？');
			if(flag){
				$('.main').css('display','block');
				$('.plat').css('display','none');
				}
			});
		
		})
 </script>
 <style type='text/css'>
 	.main{border:solid 2px;width:750px;height:450px;margin:100px auto;background:gray}
 	#div1{font-size:35px;text-align:center}
 	#div2{float:right;font-size:25px;border:1px;width:400px;}
 	#div3{color:orange;text-align:center}
 	#d1{color:red;}
 	#div5{text-align:center}
	.start{width:150px;height:50px;font-size:30px;color:green}
	.plat{display:none;border:solid 2px;width:750px;height:450px;margin:100px auto;background:gray;}
 	#puter{border:solid;height:250px;width:250px;float:left}
 	#div6{font-size:168px;color:orange;}
 	#div0{font-size:168px;color:orange;}
 	#sur{float:left;width:180px;height:170px;border:solid;text-align:center;margin:35px auto}
 	#div7{color:red}
	#player{border:solid;height:250px;width:250px;float:left}
	#but{color:red;font-size:20px;padding:30px;text-align:center}
	#alert{text-align:center;color:orange;width:200px;height:30px;margin:auto}
 </style>
 </head>
 <body>
 	<div class="main">
    <br/>
 	  <div id="div1">比大小游戏 </div>
 		 <br/>
 		 <br/>
		<img src="welcome.png"/>
		<div id="div2">
			<div id="div3">比大小排行</div>
			 <br/>
			<div id="d1">第一名	：</div>
			 <br/>
			<div id="d2">第二名	：</div>
			 <br/>
			<div id="d3">第三名	：</div>
			 <br/>
			 <br/>
				<div id="div5">
					<button class='start'>Begin</button>
				</div>
		 </div>
 	</div>
 	<div class='plat'>
 	 <div id="div1">比大小游戏 </div>
 	 <div id="alert"></div>
 	<br/>
 	<br/>
 		<div id="puter">电脑
 			<div id="div6">???</div>
 		</div>
 		
 		<div id="sur">
 		   <br/>
 			<div id="div7">分数	<span id=span>0</span></div>
 			<br/>
 			<br/>
 			生命	 <span id="span1">3</span>
 		</div>
 	
 		<div id="player">玩家
 			<div id="div0">???</div>
 		</div>
	 	
	 	<div id="but">
		 	<button id="compare">比一比</button>
			<button id="stop">不玩了</button>	
	 	</div>
 	 </div>
 </body>
</html>
